#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>

#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
	int fd;
	char wbuf[50],rbuf[50];
	int ret;
	
	fd = open(argv[1],O_RDWR);
	if(fd < 0){
		perror("open");
		exit(1);
	}

	printf("pls input a string:");
	//scanf()
	//gets(wbuf);
	fgets(wbuf,50,stdin);
	ret = write(fd,wbuf,sizeof(wbuf));
	if(ret < 0){
		perror("write");
		exit(1);
	}
	
	ret = read(fd,rbuf,sizeof(rbuf));
	if(ret < 0){
		perror("read");
		exit(1);
	}
	printf("read str from kernel:%s\n",rbuf);
	
	close(fd);
	return 0;
}


